const cloud = require('wx-server-sdk')
const axios = require('axios')
cloud.init()
exports.main = async (event) => {
  const { userMsg } = event
  try {
    const response = await axios.post('https://api.deepseek.com/v1/chat/completions', {
      model: "deepseek-chat",
      messages: [{role: "user", content: userMsg}]
    }, {
      headers: { 'Authorization': `Bearer sk-63f5d301a22d4d8abe8f23adc1737637` }
    })
    return response.data.choices[0].message.content
  } catch (error) {
    return { errMsg: error.response.data.error.message }
  }
}